                            # 动手试一试
# 8-1 消息
def display_message():
    """指出本章学的是什么"""
    print("本章学的是函数")

display_message()
# 8-2 喜欢的图书
def favorite_book(bookname):
    """指出我喜欢的图书之一"""
    print("One of my favorite book is " + bookname)

favorite_book("Alice in Wonderland")
# 8-3 T恤
def make_shirt(size, words):
    print("这是一件" + str(size) + "码的，"
          "印有“" + words + "”字样的T恤"  )

make_shirt(180, '我爱中国')
# 8-4 大号T恤
def make_shirt(size = 175, words = 'I love Python'):
    print("这是一件" + str(size) + "码的，"
          "印有“" + words + "”字样的T恤"  )
make_shirt()
make_shirt(180)
make_shirt(180, 'I love Java')
# 8-5 城市
def describe_city(city_name, country = 'china'):
    print(city_name.title() +  " is in " + country.title())

describe_city('reykjavik', 'iceland')
describe_city('chengdu')
describe_city("xi'an")
# 8-6 城市名
def city_country(city_name, country):
    city_info = city_name.title() + ", " + country.title()
    return city_info

print(city_country('santiago', 'chile'))
# 8-7 专辑
def make_album(singer_name, album_name):
    """创建一个描述音乐专辑的字典"""
    album_dic = {
        '歌手': singer_name,
        '专辑': album_name,
    }
    return album_dic

print(make_album('陈雪凝', '拾陆'))
# 8-8 用户的专辑
active = True
while active:
    singer_name = input("\n请输入歌手名（输入'q'退出）：")
    if singer_name == 'q':
        break
    album_name = input("\n请输入专辑名（输入'q'退出）：")
    if album_name == 'q':
        break

    print(make_album(singer_name, album_name))
# 8-9 魔术师
def show_magicians( magicians_names):
    for magicians_name in magicians_names:
        print(magicians_name.title())

magicians_names = ['tom', 'david', 'sam', 'jack']

show_magicians(magicians_names)
# 8-10 了不起的魔术师
def show_magicians(magicians_names):
    for magicians_name in magicians_names:
        print(magicians_name.title())

def make_great(magicians_names):
    great_magicians_name = []
    for magicians_name in magicians_names:
        great_magicians_name.append("the great " + magicians_name)
    return great_magicians_name

magicians_names = ['tom', 'david', 'sam', 'jack']

show_magicians(make_great(magicians_names))

# 8-11 不变的魔术师
def show_magicians(magicians_names):
    for magicians_name in magicians_names:
        print(magicians_name.title())

def make_great(magicians_names):
    for i in range(0, len(magicians_names)):
        magicians_names[i] = "the Great " +  magicians_names[i]
    return magicians_names

magicians_names = ['tom', 'david', 'sam', 'jack']

show_magicians(make_great(magicians_names[:]))
show_magicians(magicians_names)
# 8-12 三明治
def add_ingredients(*ingredients):
    print("\nMakeing a sandwich with the following ingredients:")
    for ingredient in ingredients:
        print("- " + ingredient)

add_ingredients("egg", "sausages", "tomatoes")
# 8-13 用户简介
def self_introduction(first_name, last_name, **info):
    myself = {}
    myself['姓'] = first_name
    myself['名'] = last_name
    for key, val in info.items():
        myself[key] = val
    return myself

print("\n----自我介绍----")
print(self_introduction("徐","皓玮",爱好 = "唱、跳、rap、篮球",
                  年龄 = 19, 星座 = "水瓶座"))
# 8-14 汽车
def make_car(manufacturer, type, **car_info):
    profile = {}
    profile['制造商'] = manufacturer
    profile['型号'] = type
    for key, value in car_info.items():
        profile[key] = value
    return profile

print(make_car('subaru', 'outback', color = 'blue', tow_package = True))
# 8-15 打印模型
# 8-16 导入